﻿@model IEnumerable<HanGu.Entity.Module>
@{
    Layout = null;
    int i = 1;
    ViewBag.ViewTitle = "模块";
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam;
    //var moduleList = ViewData["ModuleList"] as SelectList;
}
<form id="pagerForm" method="get" action="/admin/@ViewData["CurrentController"]/index">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
<input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
<input type="hidden" name="orderField" value="${param.orderField}" />
<input type="hidden" name="Title" value="@SearchParma.Ttile" />
<input type="hidden" name="IntObj1" value="@SearchParma.IntObj1" />
</form>
<style>
    .tbleFirstcat
    {
        background-color: #999;
        font-weight: bold;
        color: #fff;
    }
    .tbleFirstcat:hover
    {
        color: #000;
    }
    .tbleSecondcat
    {
        background-color: #ccc;
        font-weight: bold;
        color: #fff;
    }
    .tbleSecondcat:hover
    {
        color: #000;
    }
</style>
<div class="pageContent">
    @Html.Partial("Buttons")
    <table class="list" width="100%" layouth="30">
        <thead>
            <tr class="header">
                <th>
                    序号
                </th>
                <th>
                    ID
                </th>
                <th>
                    名称
                </th>
                <th>
                    URL
                </th>
                <th>
                    排序
                </th>
                <th>
                    父ID
                </th>
                <th>
                    类型
                </th>
                <th>
                    参数格式
                </th>
                <th>
                    点击事件
                </th>
                <th>
                    打开方式
                </th>
                <th>
                    是否外部
                </th>
                <th>
                    允许刷新
                </th>
                <th>
                    CssClass
                </th>
                <th>
                    备注
                </th>
            </tr>
        </thead>
        @foreach (var parent in Model.Where(c => string.IsNullOrEmpty(c.Parent)).OrderBy(c => c.Order))
        {
            i = 1;        
            <tr class="tbleFirstcat">
                <td colspan="14">
                    <b>@parent.ModuleName</b>
                </td>
            </tr>
            
            foreach (var modules in Model.Where(c => c.Parent == parent.ID).OrderBy(c => c.Order))
            {
                var modulesAndRoles = new List<HanGu.Entity.Module>();
                modulesAndRoles.Add(modules);
                modulesAndRoles.AddRange(Model.Where(c => c.Parent == modules.ID).OrderBy(c => c.Order));
                var secondcat = true;
                foreach (var item in modulesAndRoles)
                {                    
            <tr style="@(secondcat ? "background-color:#ccc" : null)" >
                <td>
                    @i
                </td>
                <td>
                    @item.ID
                </td>
                <td title="@item.Title">
                    @item.ModuleName
                </td>
                <td>
                    @item.Url
                </td>
                <td>
                    @item.Order
                </td>
                <td>
                    @item.Parent
                </td>
                <td>
                    @{
                    var ModuleTypes = (HanGu.Entity.Enum.CommEnum.ModuleTypes)item.Types;
                        @ModuleTypes
                    }
                </td>
                <td>
                    @item.ParmFormat
                </td>
                <td>
                    @item.OnCilck
                </td>
                <td>
                    @item.Target
                </td>
                <td>
                    @item.External
                </td>
                <td>
                    @item.Fresh
                </td>
                <td>
                    @item.CssClass
                </td>
                <td>
                    @item.Remark
                </td>
            </tr>
                    secondcat = false;
                    i += 1;
                }
            }
        }
    </table>
</div>
